Creating a new Zendesk integration via the API

Hey there !

Trying to automate the integration creation process.
I have 70-80 services, which needs to be integrated with Zendesk API and get the Integration Keys

  • UPDATED THE QUESTION *

Trying to make this request (To create a Zendesk API integration):

const axios = require('axios');
let data = JSON.stringify({
  "integration": {
    "type": "app_event_transform_inbound_integration",
    "name": "Zendesk API",
    "service": {
      "id": "X",
      "type": "service_reference"
    },
    "integration_email": "X",
    "vendor": {
      "id": "PEP6E4P",
      "type": "vendor_reference",
      "summary": "Zendesk API",
      "self": "https://api.pagerduty.com/vendors/PEP6E4P",
      "html_url": null
    }
  }
});

let config = {
  method: 'post',
  url: 'https://api.pagerduty.com/services/X/integrations',
  headers: { 
    'Accept': 'application/vnd.pagerduty+json;version=2', 
    'Authorization': 'Token token=X', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

Respone :

{
    "error": {
        "message": "Access Denied",
        "code": 2010
    }
}

Any suggestions ?

Hi Eyal,

We have a Zendesk integration guide available here: https://support.pagerduty.com/docs/zendesk-integration-guide

If you have any specific questions about setting this up, feel free to email us (support@pagerduty.com) and we’d be happy to help.

Thanks,

Hey abbot,

You didn’t understand me well…
I don’t mean to create the Zendesk - PagerDuty integration

I mean to add a Zendesk Integration to a technical service and get the integration key via the API

Hi Eyal,

You may be looking for setting this up via the Zendesk V2 integration we have listed here: https://support.pagerduty.com/docs/zendesk-v2-integration-guide

The V2 is a legacy version, but is still compatible with PagerDuty.

Abbott Brannon
Technical Support Specialist

updated the question.please look again :pray:

Just a quick thing to check is that you have a manager or higher role for all of those services.

Thanks for the reply Doug, I got Admin permssions

Is there an option that we cant create that integration via the API …?

Hi Eyal,

Our current types of Integrations that can be built via our API are listed below:

aws_cloudwatch_inbound_integration, cloudkick_inbound_integration, event_transformer_api_inbound_integration, generic_email_inbound_integration, generic_events_api_inbound_integration, keynote_inbound_integration, nagios_inbound_integration, pingdom_inbound_integration, sql_monitor_inbound_integration, events_api_v2_inbound_integration.

I’ve shared your request to be able to create this integration with our product team via a Feature Request.

Thanks,

Abbott Brannon
Technical Support Specialist

I’m not familiar with the exact Zendesk integration payload, but having this “integration_email”: “X” in there caught my eye if this is an API integration.

I usually get things configured/working via the UI first, then do a GET on that working integration so I can create an API payload template (removing fields I don’t need for a POST).

If you want to share a full API response from a GET on a working integration you have on a service, I can help you take a look at turning that into a payload to create those on all your services.

this is the response for viewing the integration :
Thanks

{
  "integration": {
    "id": "x",
    "type": "app_event_transform_inbound_integration",
    "summary": "Zendesk API",
    "self": "https://api.pagerduty.com/services/x/integrations/x",
    "html_url": "https://x.pagerduty.com/services/x/integrations/x",
    "name": "Zendesk API",
    "service": {
      "id": "x",
      "type": "service_reference",
      "summary": "x",
      "self": "https://api.pagerduty.com/services/x",
      "html_url": "https://x.pagerduty.com/service-directory/x"
    },
    "created_at": "2021-12-25T18:13:31+02:00",
    "vendor": {
      "id": "PEP6E4P",
      "type": "vendor",
      "summary": "Zendesk API",
      "self": "https://api.pagerduty.com/vendors/PEP6E4P",
      "html_url": null,
      "name": "Zendesk API",
      "website_url": "http://www.zendesk.com/",
      "long_name": "Zendesk API",
      "logo_url": "https://s3.amazonaws.com/pdpartner/zendesk_large_logo.png",
      "thumbnail_url": "https://s3.amazonaws.com/pdpartner/zendesk_thumbnail_logo.png",
      "description": "",
      "integration_guide_url": "https://support.pagerduty.com/docs/zendesk-integration-guide",
      "connectable": false,
      "generic_service_type": "api",
      "alert_creation_default": "create_alerts_and_incidents",
      "alert_creation_editable": true,
      "is_pd_cef": true,
      "is_pd_change_event": false,
      "developer_name": "",
      "support_portal": "",
      "support_email": "",
      "documentation_url": "https://support.pagerduty.com/docs/zendesk-integration-guide",
      "emits_change_events": false
    },
    "integration_key": "x"
  }
}

Using Eyal’s payload from the GET response, I was able to remove unnecessary fields and make a successful POST request to create new Zendesk integration. Request example using axios below:

var axios = require('axios');
var data = JSON.stringify({
  "integration": {
    "type": "app_event_transform_inbound_integration",
    "name": "Zendesk API",
    "service": {
      "id": "REDACTED",
      "type": "service_reference"
    },
    "vendor": {
      "id": "PEP6E4P",
      "type": "vendor",
      "summary": "Zendesk API"
    }
  }
});

var config = {
  method: 'post',
  url: 'https://api.pagerduty.com/services/REDACTED/integrations',
  headers: { 
    'Authorization': 'Token token=REDACTED', 
    'Accept': 'application/vnd.pagerduty+json;version=2', 
    'Content-Type': 'application/json, application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

Kat Kasianenko

1 Like

Thanks you Mate !
Works for me

Thanks for beating me to it Kat! :handshake: